import org.junit.Test;

/**
 * Created by luoxf on 2018/8/18.
 */
public class Algorithm {

    /**
     * 去除两个字符串中相同的字符
     */
    @Test
    public void testA() {
        String str = "ar1qwerty";
        String str1 = "qqwer1z";
        String[] check = this.check(str, str1);
        System.out.println("str: " + check[0]);
        System.out.println("str1: " + check[1]);
    }

    public String[] check(String str, String str1) {
        char[] c = str.toCharArray();
        char[] c1 = str1.toCharArray();
        StringBuffer s = new StringBuffer();
        StringBuffer s1 = new StringBuffer();
        for (int i = 0; i < c.length; i++) {
            boolean flag = true;
            char a = 0;
            for (int j = 0; j < c1.length; j++) {
                /*if (c[i] == (c1[j])) {
                    str = str.replaceAll(String.valueOf(c[i]), "");
                    str1 = str1.replaceAll(String.valueOf(c[i]), "");
                }*/
                a = c1[j];
                if (c[i] == (c1[j])) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                s.append(c[i]);
                s1.append(a);
            }
        }
        return new String[]{s.toString(), s1.toString()};
    }
}
